/*
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved.
 */
package com.hbisdt.cet.sample.servlet;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 过滤器示例
 *
 * @author : 教学示例
 * @version : 1.0
 * @date : 2025-02-11 15:00
 */
@WebFilter(urlPatterns = "/filter/login")
//@Component
public class FilterSample implements Filter {

    /**
     * 初始化方法
     *
     * @author : 教学示例
     */
    @Override
    public void init(FilterConfig filterConfig) {
        System.out.println("FilterSample init");
    }

    /**
     * 过滤执行方法
     *
     * @author : 教学示例
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("Filter execute");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    /**
     * 过滤器销毁时调用
     *
     * @author : 教学示例
     */
    @Override
    public void destroy() {
        System.out.println("FilterSample destroy");
    }
}
